﻿using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace OpenLS.Spreadsheet.Formats.Biff.Records
{
    internal class HorizontalPageBreaksRecord : WorksheetLevelRecord
    {
        internal override BiffRecordType RecordType
        {
            get { return BiffRecordType.HorizontalPageBreaks; }
        }

        internal override void Apply(BiffReaderWorksheetContext context)
        {
            Debug.WriteLine("Applying horizotnalpage breaks");

        }

        internal override void WriteContent(BiffWriterWorkbookContext context)
        {
            ushort u = (ushort) breaks.Count;
            context.WriteUInt16(u);
            foreach (var item in this.breaks)
                item.Write(context.Writer);
        }

        protected override void ReadContent(BiffReaderContext context, int length)
        {
            ushort cbrk = context.ReadUInt16();
            for (int i = 0; i < cbrk; i++)
            {
                HorzBrk brk = new HorzBrk();
                brk.Read(context.Reader);
                this.breaks.Add(brk);
            }
        }
        List<HorzBrk> breaks = new List<HorzBrk>();
    }
}